#include<iostream>
using namespace std;
const int N = 1e3 + 10, M = N * 2;
int n, m;
int dfn[N], low[N], tot;
int in_stk[N], stk[N], top;
int h[N], ne[M], e[M], idx;
int w[N];
int scc[N], sz[N];
int g[N][N];
int scc_cnt;
int dis[N];
bool st[N];
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
void tarjan(int u)
{
	dfn[u] = low[u] = ++tot;
	in_stk[u] = 1;
	stk[++top] = u;
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (!dfn[j]) {
			low[u] = min(low[u], low[j]);
		}
		else if (in_stk[j]) {
			low[u] = min(low[u], dfn[j]);
		}
	}
	if (dfn[u] == low[u]) {
		int y;
		scc_cnt++;
		do {
			y = stk[top--];
			in_stk[y] = 0;
			scc[y] = scc_cnt;
			sz[scc_cnt]++;
		} while (u != y);
	}
}

void dij(int s)
{
	memset(dis, 0x3f, sizeof(dis));
	dis[s] = 0;
	for (int i = 0; i < n; i++) {
		int t = -1;
		for (int j = 1; j <= n; j++) {
			if (!st[j] && (t == -1 || dis[t] > dis[j])) {
				t = j;
			}
		}
		st[t] = 1;
		for (int j = 1; j <= n; j++) {
			dis[j] = min(dis[j], dis[t] + g[t][j]);
		}
	}
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> w[i];
	}
	while (m--) {
		int a, b;
		cin >> a >> b;
		add(a, b);
		add(b, a);
		
	}
	dfs(1, 0);
	
	return 0;
}